<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>generator生成器</title>
</head>
<body>
  <script>
    // 模拟异步函数
    function Async2 () {
      setTimeout(() => {
        Promise.resolve(runFun.next('async2'));
      }, 2000);
    }
    function Async1 () {
      setTimeout(() => {
        Promise.resolve(runFun.next('async1'));
      }, 1000);
    }
    function *run () {
      const res2 = yield Async2();
      console.log('res2', res2);
      const res1 = yield Async1();
      console.log('res1', res1);
    }
    const runFun = run();
    runFun.next();
  </script>
</body>
</html>